/*
 * 作者：姚俊
 * 功能：把相应的Map对象转化成相应的bean
 * 日期：2015-07-10
 */
package beanDao;

import java.util.Map;

import admin.bean.Innovations;
import admin.bean.Platform;

import teacher.bean.Award;
import teacher.bean.Paper;
import teacher.bean.Patent;
import teacher.bean.Project;
import teacher.bean.Stuaward;
import teacher.bean.Studegreepaper;
import teacher.bean.Stuproject;
import teacher.bean.Teacher;
import teacher.bean.Treatise;
import tools.StringDate;

public class MapToBean {

	/**
	 * @category 把Map转化成教师对象
	 * @param map
	 * @return
	 */
	public Teacher MapToTeacher(Map map)
	{
		Teacher tea=new Teacher();
		try {	
			
			tea.setTeaId(Integer.parseInt(map.get(0).toString()));
			tea.setName((String) map.get(1));
			tea.setUser((String) map.get(2));
			tea.setPassword((String) map.get(3));
			try {
				tea.setSubject(Integer.parseInt((String)map.get(4)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				tea.setSubject(null);
				e.printStackTrace();
			}
			try {
				tea.setDirection(Integer.parseInt(map.get(5).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				tea.setDirection(null);
				e.printStackTrace();
			}
			tea.setDuty((String)map.get(6));
			try {
				tea.setDegree(Integer.parseInt(map.get(7).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				tea.setDegree(null);
				e.printStackTrace();
			}
			try {
				tea.setOnline(Integer.parseInt((String)map.get(8)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				tea.setOnline(null);
				e.printStackTrace();
			}
			try {
				tea.setBirthday(StringDate.StringToDate(map.get(9).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				tea.setBirthday(null);
				e.printStackTrace();
			}
			tea.setFurStud((String)map.get(10));
			tea.setTopSchool((String)map.get(11));
			tea.setTopMajor((String)map.get(12));
			tea.setMail((String)map.get(13));
			try {
				tea.setPower(Integer.parseInt(map.get(14).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				tea.setPower(null);
				e.printStackTrace();
			}
			try {
				tea.setInSubDate(StringDate.StringToDate((String)map.get(15)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				tea.setInSubDate(null);
				e.printStackTrace();
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return tea;
	}
	
	
	
	/**
	 * @category 把Map转化成项目对象
	 * @param map
	 * @return
	 */
	public Project MapToProject(Map map)
	{
		Project p = new Project();
		try {
			
			p.setProId(Integer.parseInt(map.get(0).toString()));
			p.setName((String)map.get(1));
			try {
				p.setLevel(Integer.parseInt(map.get(2).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				p.setLevel(null);
				e.printStackTrace();
			}
			p.setSource((String)map.get(3));
			try {
				p.setFunds(Integer.parseInt(map.get(4).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				p.setFunds(null);
				e.printStackTrace();
			}
			try {
				p.setArriveFunds(Integer.parseInt(map.get(5).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				p.setArriveFunds(null);
				e.printStackTrace();
			}
			p.setLeader((String)map.get(6));
			p.setOthers((String)map.get(7));
			try {
				p.setBeginDate(StringDate.StringToDate(map.get(8).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				p.setBeginDate(null);
				e.printStackTrace();
			}
			try {
				p.setState(Integer.parseInt(map.get(9).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				p.setState(null);
				e.printStackTrace();
			}
			p.setLowDepartment((String)map.get(10));
			try {
				p.setClass_(Integer.parseInt(map.get(11).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				p.setClass_(null);
				e.printStackTrace();
			}
			p.setNumber((String)map.get(12));
			try {
				p.setFinishDate(StringDate.StringToDate(map.get(13).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				p.setFinishDate(null);
				e.printStackTrace();
			}
			p.setUpload((String)map.get(14));
			try {
				p.setTeaId(Integer.parseInt(map.get(15).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				p.setTeaId(null);
				e.printStackTrace();
			}
			try {
				p.setKind(Integer.parseInt(map.get(16).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				p.setKind(null);
				e.printStackTrace();
			}
			try {
				p.setProgress(Integer.parseInt(map.get(17).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				p.setProgress(null);
				e.printStackTrace();
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return p;
	}
	
	/**
	 * @category 把Map转化成论著对象
	 * @param map
	 * @return
	 */
	public Treatise MapToTreatise(Map map)
	{
		Treatise t = new Treatise();
		try {
			t.setTreId(Integer.parseInt(map.get(0).toString()));
			t.setName((String)map.get(1));
			t.setAuthor((String)map.get(2));
			try {
				t.setDate(StringDate.StringToDate(map.get(3).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				t.setDate(null);
				e.printStackTrace();
			}
			try {
				t.setState(Integer.parseInt(map.get(4).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				t.setState(null);
				e.printStackTrace();
			}
			t.setClass_(Integer.parseInt(map.get(5).toString()));
			t.setPress((String)map.get(6));
			t.setAbstract_((String)map.get(7));
			t.setUpload((String)map.get(8));
			t.setBookNum((String)map.get(9));
			try {
				t.setTeaId(Integer.parseInt(map.get(10).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				t.setTeaId(null);
				e.printStackTrace();
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return t;
	}
	
	/**
	 * @category 把Map转化成专利对象
	 * @param map
	 * @return
	 */
	public Patent MapToPatent(Map map)
	{
		Patent pat=new Patent();
		try {			
			pat.setPatId(Integer.parseInt(map.get(0).toString()));
			pat.setName((String)map.get(1));
			pat.setFiestInventor((String)map.get(2));
			try {
				pat.setEmpowerDate(StringDate.StringToDate(map.get(3).toString()));
			} catch (Exception e4) {
				// TODO Auto-generated catch block
				pat.setEmpowerDate(null);
				e4.printStackTrace();
			}
			pat.setEmpowerUnit((String)map.get(4));
			try {
				pat.setTransferFunds(Integer.parseInt(map.get(5).toString()));
			} catch (Exception e3) {
				// TODO Auto-generated catch block
				pat.setTransferFunds(null);
				e3.printStackTrace();
			}
			try {
				pat.setExamine(Integer.parseInt(map.get(6).toString()));
			} catch (Exception e2) {
				// TODO Auto-generated catch block
				pat.setExamine(null);
				e2.printStackTrace();
			}
			pat.setApplyNumber((String)map.get(7));
			pat.setNumber((String)map.get(8));
			pat.setUpload((String)map.get(9));
			try {
				pat.setTeaId(Integer.parseInt(map.get(10).toString()));
			} catch (Exception e2) {
				// TODO Auto-generated catch block
				pat.setTeaId(null);
				e2.printStackTrace();
			}
			try {
				pat.setExpClass(Integer.parseInt(map.get(11).toString()));
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				pat.setExpClass(null);
				e1.printStackTrace();
			}
			pat.setEmpowerNum((String)map.get(12));
			try {
				pat.setApplyDate(StringDate.StringToDate(map.get(13).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				pat.setApplyDate(null);
				e.printStackTrace();
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return pat;
	}
	
	
	/**
	 * @category 把Map转化成论文对象
	 * @param map
	 * @return
	 */
	public Paper MapToPaper(Map map)
	{
		Paper paperTwo = new Paper();
		try {
			paperTwo.setPapId(Integer.parseInt(map.get(0).toString()));
			paperTwo.setName((String)map.get(1));
			paperTwo.setFauthor((String)map.get(2));
			paperTwo.setPbulication((String)map.get(3));
			paperTwo.setPubNumber((String)map.get(4));
			try {
				paperTwo.setInclude(Integer.parseInt((String)map.get(5)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				paperTwo.setInclude(null);
				e.printStackTrace();
			}
			try {
				paperTwo.setQuoteNum(Integer.parseInt((String)map.get(6)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				paperTwo.setQuoteNum(null);
				e.printStackTrace();
			}
			try {
				paperTwo.setState(Integer.parseInt((String)map.get(7)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				paperTwo.setState(null);
				e.printStackTrace();
			}
			paperTwo.setUpload((String)map.get(8));
			paperTwo.setPubPage((String)map.get(9));
			try {
				paperTwo.setDate(StringDate.StringToDate((String)map.get(10)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				paperTwo.setDate(null);
				e.printStackTrace();
			}
			try {
				paperTwo.setTopStu(Integer.parseInt((String)map.get(11)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				paperTwo.setTopStu(null);
				e.printStackTrace();
			}
			paperTwo.setTauthor((String)map.get(12));
			paperTwo.setOauthor((String)map.get(13));
			paperTwo.setVolume((String)map.get(14));
			try {
				paperTwo.setTeaId(Integer.parseInt((String)map.get(15)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				paperTwo.setTeaId(null);
				e.printStackTrace();
			}
			try {
				paperTwo.setType(Integer.parseInt((String)map.get(16)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				paperTwo.setType(null);
				e.printStackTrace();
			}
			try {
				paperTwo.setEsi(Integer.parseInt((String)map.get(17)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				paperTwo.setEsi(null);
				e.printStackTrace();
			}
			try {
				paperTwo.setJclass(Integer.parseInt((String)map.get(18)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				paperTwo.setJclass(null);
				e.printStackTrace();
			}
			paperTwo.setIncludNum((String)map.get(19));
			try {
				paperTwo.setMeetClass(Integer.parseInt((String)map.get(20)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				paperTwo.setMeetClass(null);
				e.printStackTrace();
			}
			paperTwo.setMeetName((String)map.get(21));
			paperTwo.setMeetPlace((String)map.get(22));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return paperTwo;
	}

	/**
	 * @category 把map转化成相应获奖的对象，后台Service调用
	 * @param map
	 * @return
	 */
	public Award MapToAward(Map map)
	{
		Award a = new Award();
		try {
			a.setAwaId(Integer.parseInt(map.get(0).toString()));
			a.setName((String)map.get(1));
			a.setProjectName((String)map.get(2));
			try {
				a.setLevel(Integer.parseInt(map.get(3).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				a.setLevel(null);
				e.printStackTrace();
			}
			a.setPeople((String)map.get(4));
			try {
				a.setDate(StringDate.StringToDate(map.get(5).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				a.setDate(null);
				e.printStackTrace();
			}
			a.setNumber((String)map.get(6));
			a.setUpload((String)map.get(7));
			try {
				a.setTeaId(Integer.parseInt(map.get(8).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				a.setTeaId(null);
				e.printStackTrace();
			}
			try {
				a.setState(Integer.parseInt(map.get(9).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				a.setState(null);
				e.printStackTrace();
			}
			
			try {
				a.setKind(Integer.parseInt(map.get(10).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				a.setKind(null);
				e.printStackTrace();
			}
			try {
				a.setUnitNum(Integer.parseInt(map.get(11).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				a.setUnitNum(null);
				e.printStackTrace();
			}
			a.setEmpowerUnit((String)map.get(12));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return a;
	}
	
	
	/**
	 * @category 把map转化成相应的建设平台对象，后台Service调用
	 * @param map
	 * @return
	 */
	public Platform MapToPlatform(Map map)
	{
		Platform pla=new Platform();
		try {
			
			pla.setPlaId(Integer.parseInt(map.get(0).toString()));
			pla.setName((String)map.get(1));
			try {
				pla.setLevel(Integer.parseInt(map.get(2).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				pla.setLevel(null);
				e.printStackTrace();
			}
			pla.setApprovedDepartment((String)map.get(3));
			pla.setApprovedDate((String)map.get(4));
			try {
				pla.setSubjectId(Integer.parseInt(map.get(5).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				pla.setSubjectId(null);
				e.printStackTrace();
			}
			try {
				pla.setClassify(Integer.parseInt(map.get(6).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				pla.setClassify(null);
				e.printStackTrace();
			}		
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}	
		
		return pla;
	}
	
	
	/**
	 * @category 把map转化成相应的创新团队对象，后台Service调用
	 * @param map
	 * @return
	 */
	public Innovations MapToInnovations(Map map)
	{
		Innovations inn=new Innovations();
		 try {
				
				inn.setInnId(Integer.parseInt(map.get(0).toString()));
				inn.setName((String)map.get(1));
				try {
					inn.setLevel(Integer.parseInt(map.get(2).toString()));
				} catch (Exception e) {
					// TODO Auto-generated catch block
					inn.setLevel(null);
					e.printStackTrace();
				}
				inn.setSuperPerson((String)map.get(3));
				try {
					inn.setApprovedDepartment(Integer.parseInt(map.get(4).toString()));
				} catch (Exception e) {
					// TODO Auto-generated catch block
					inn.setApprovedDepartment(null);
					e.printStackTrace();
				}
				try {
					inn.setApprovedDate(map.get(5).toString());
				} catch (Exception e) {
					// TODO Auto-generated catch block
					inn.setApprovedDate(null);
					e.printStackTrace();
				}
				try {
					inn.setSubjectId(Integer.parseInt(map.get(6).toString()));
				} catch (Exception e) {
					// TODO Auto-generated catch block
					inn.setSubjectId(null);
					e.printStackTrace();
				}
				try {
					inn.setClassify(Integer.parseInt(map.get(7).toString()));
				} catch (Exception e) {
					// TODO Auto-generated catch block
					inn.setClassify(null);
					e.printStackTrace();
				}				
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}	
		 
		 return inn;
	}
	
	/**
	 * @category 把map转化成相应的学生学位论文对象，后台Service调用
	 * @param map
	 * @return
	 */
	public Studegreepaper MapToStudegreepaper(Map map)
	{
		Studegreepaper degreePaperTwo = new Studegreepaper();
		try {
			
			degreePaperTwo.setDegId(Integer.parseInt(map.get(0).toString()));
			degreePaperTwo.setDegname((String)map.get(1));
			try {
				degreePaperTwo.setDegaward(Integer.parseInt(map.get(2).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				degreePaperTwo.setDegaward(null);
				e.printStackTrace();
			}
			degreePaperTwo.setUpload((String)map.get(3));
			try {
				degreePaperTwo.setStuId(Integer.parseInt(map.get(4).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				degreePaperTwo.setStuId(null);
				e.printStackTrace();
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		return degreePaperTwo;
	}
	
	
	/**
	 * @category 把map转化成相应的学生获奖对象，后台Service调用
	 * @param map
	 * @return
	 */
	public Stuaward MapToStuaward(Map map)
	{
		Stuaward stuAwardTwo = new Stuaward();
		try {
			
			stuAwardTwo.setStuawaId(Integer.parseInt(map.get(0).toString()));
			stuAwardTwo.setAwaname((String)map.get(1));
			try {
				stuAwardTwo.setAwalevel(Integer.parseInt(map.get(2).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				stuAwardTwo.setAwalevel(null);
				e.printStackTrace();
			}
			try {
				stuAwardTwo.setAwakind(Integer.parseInt(map.get(3).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				stuAwardTwo.setAwakind(null);
				e.printStackTrace();
			}
			stuAwardTwo.setDepartment((String)map.get(4));
			try {
				stuAwardTwo.setStuId(Integer.parseInt(map.get(5).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				stuAwardTwo.setStuId(null);
				e.printStackTrace();
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return stuAwardTwo;
	}
	
	/**
	 * @category 把map转化成相应的学生项目对象，后台Service调用
	 * @param map
	 * @return
	 */
	public  Stuproject MapToStuproject(Map map)
	{
		Stuproject stuProjectTwo = new Stuproject();
		try {
			
			stuProjectTwo.setStuproId(Integer.parseInt(map.get(0).toString()));
			stuProjectTwo.setProname((String)map.get(1));
			try {
				stuProjectTwo.setProlevel(Integer.parseInt(map.get(2).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				stuProjectTwo.setProlevel(null);
				e.printStackTrace();
			}
			stuProjectTwo.setProsource((String)map.get(3));
			try {
				stuProjectTwo.setStuId(Integer.parseInt(map.get(4).toString()));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				stuProjectTwo.setStuId(null);
				e.printStackTrace();
			}	
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return stuProjectTwo;
	}

}
